#ifndef IMAMUTIL_H
#define IMAMUTIL_H

#define TLE_MAX_DATA_SZ		500
#define MODE_ECB			1			// Electronic Code Book
#define MODE_CBC			2			// Cipher Block Chaining
#define PAD_NULL			1		// Pad with Nulls
#define PAD_NULL_NUM_BYTES	2		// Pad with Nulls and end with Number of Bytes
#define AES_BLOCK_SIZE	16			// Bytes
#define AES_KEY_LENGTH	16			// Bytes

#ifdef IMAM_AES_OMNI
typedef struct libencrypt
{
	int iEncryptAlgo;
	int	iMode;	
	int iPadChar;
	int iBlockSize;
	int iKeyLen;
	// This function allows the specific encryption implementation to initialize 
	//	the contents of this cryptolib structure
	// iMode = 0 means use the default value.
	int (*Init)	   (int, int, struct libencrypt *);
	// Function pointer to the specific encryption function
	int (*iEncrypt)(	unsigned char *, int ,
						unsigned char *, int *,
						unsigned char *, int ,
						struct libencrypt *);
	// Function pointer to the specific decryption function
	int (*iDecrypt)(	unsigned char *, int,
						unsigned char *, int *,
						unsigned char *, int, 
						struct libencrypt *);
} LIBENCRYPT;
#endif

int fSSL(void);
int fAES(void);
#ifndef __arm
int inAES_Encrypt (char *szData, int inDataLen);
int inAES_Decrypt (char *szEncData, int inEncDataLen);
int inImamAesEncrypt (unsigned char *ucInput, int inInputLen, unsigned char *ucOutput, int *inOutputLen);
int inImamAesDecrypt (unsigned char *ucInput, int inInputLen, unsigned char *ucOutput, int *inOutputLen);
#endif
#ifdef __arm
int inImamAesEncrypt (unsigned char *ucInput, int inInputLen, unsigned char *ucOutput, int *inOutputLen);
int inImamAesDecrypt (unsigned char *ucInput, int inInputLen, unsigned char *ucOutput, int *inOutputLen);
#endif

int fImamSale(void);
int fImamSSP(void);
int fImamOR(void);
int fImamCardVer(void);
int fImamPrintCardVer(void);
int fImamAuthOnly(void);
int fImamNormPreAuth(void);
int fImamOffline(void);
int fImamRefund(void);
int fImamTipAdjust(void);
int fImamTipPrompt(void);
int fImamPreAuth(void);
int fImamPreComp(void);
int inUseSNasTID(void);
int inImamEMVFallback(void);
int inImamEMVFullFallback(void);
int inImamEmaMasking(void);
void DisplayTopLogo(int Mode);
void ClearTopLogo(int Mode);
int inImamDisplayBatteryLevel(int inBatteryLevel);

void DisplayStatus(char *msg);
void ClearStatusLine(void);
int InputString(char *Caption, char *Buffer);
int get_str_x(char *buffer, int n, char ucSeparator, char *buff);
int  get_env_x(char *param, int n, char *buff);
int  put_env_x(char *param, int n, char *buff);
void LOG_PRINT_HEX(unsigned char* buf, int size);
void vdScrollDisplay(void);
int inEnablePrintISOTrace(void);
void GetTopDateTime(char *Dest);
void vdTrimSpace(char *buff);
void vdFormatText(char *buff, int kolom, int Justify);
void ClearSevenLine(void);
void ClearSixLine(void) ;
int TimeOut(unsigned long TheTime);
int inImamTimeOut(unsigned long TheTime);

//MINI ATM AUX FUNCTION
void DisplayJudul(char *msg);
void vdDisplayMerchantName(void);

int inImamGetString (char *label, char *szStr, long Min, long Max);
int inNewInputString(char *label, char *Number, long Min, long Max);
int InputPAN(char *label, char *Number, long Min, long Max, int mode, long *ret);
int InputPIN(char *label, char *Number, int MinChar, int MaxChar);
int InputNumberInd(char *label, char *Number, long Min, long Max, int mode, long *ret);
int InputNumberEngl(char *label, char *Number, long Min, long Max, int mode, long *ret);
int InputNumberWithCentEngl(char *label, char *Number, long Min, long Max, int mode, long *ret);
void vdGetCurrency(char *szCurr, char *szInput);
int FormatNumInd(char *ResBuff, long Number);
int FormatNumberInd(char *ResBuff, char *InpBuff);
int FormatNumberEngl(char *ResBuff, char *InpBuff);
int FormatNumberWithCentInd(char *ResBuff, char *InpBuff);
int FormatNumberWithCentEngl(char *ResBuff, char *InpBuff);
void vdImamFormatDate(char *Dest, char *Date);
void vdImamFormatTime(char *Dest, char *Time);
void vdMaskNameString(char *buff);
int fImamGetMKey3D(unsigned char *key) ; //edi
int fImamGetWKey3D(unsigned char *key) ; //edi

  long lnGetAndIncStanNum(void);
int inMenuChoice(char *Label, char *MenuItem1, char *MenuItem2, char *MenuItem3, char *MenuItem4);
int inHorizontalMenuChoice(char *Label, char *MenuItem1, char *MenuItem2, char *MenuItem3, char *MenuItem4);
unsigned long ulGetAndIncInvNum(void);
int inGetPrintTimes(void);
void vdImamGetFooter(int inMessageIndex, char* szMessageBuffer);
void vdImamGetEmaBitmap(int inMessageIndex, char* szMessageBuffer); 
void vdImamGetEmaData(int inMessageIndex, int inToken, char* szMessageBuffer); 
int inImamFileReadLine(unsigned char *szFileName, int inLine, unsigned char *szBuff);
int inImamPowerVxCom1(void);
int inImamDES_SD (unsigned char *szKey, unsigned char *szEncData, unsigned char *szResult);
int inImamDES_SE (unsigned char *szKey, unsigned char *szEncData, unsigned char *szResult);
int inImamDES_DD (unsigned char *szKey, unsigned char *szEncData, unsigned char *szResult);
int inImamDES_DE (unsigned char *szKey, unsigned char *szEncData, unsigned char *szResult);
int inImamDES_TD (unsigned char *szKey, unsigned char *szEncData, unsigned char *szResult);
int inImamDES_TE (unsigned char *szKey, unsigned char *szEncData, unsigned char *szResult);
void setkey(unsigned long k[][2], unsigned char *key, int decrypt);
void encrypt(unsigned long ks[16][2], unsigned char block[8]);
void DisplayStatusMSG(char *msg);
int inImamEMVFullFallback(void) ;
#ifndef IMAM_BNI
int iBniSetMKey3D( char * key);
int iBniSetWKey3D( char *key);
#endif

#endif
